import complex_query from '@feidao/web/atom/nodejs/db/complex-query';

import { spaceid, systemid } from './atom/config';

interface Message {
	filter: {
		factory_no: string;
	};
	page_size: number;
	page_no: number;
	asc: string;
	desc: string;
}

/**
 * @description in操作符
 * @param {
		filter: {
			factory_no: 'PL000001'
		},
		page_size: 20,
		page_no: 1,
		asc: 'factory_no'
	}
 */

export default async function atom(msg: Message, action_id: string, session_id: string) {
	const cquery = complex_query(action_id, spaceid, systemid);
	//添加查询字段
	cquery.add_field('factory', 'factory_name', 'factory_name')
		.add_field('factory', 'postcode', 'postcode')
		.add_field('factory', 'factory_no', 'factory_no')
		.where_in('factory', 'factory_no', ['PL000001', 'PL000002'])
		.page(msg.page_size, msg.page_no)
		.orderby(msg.asc)
		.orderby_desc(msg.desc)



	const res = await cquery.exec();
	return res;
}
